<?php
// +----------------------------------------------------------------------
// | Fanwe 方维p2p借贷系统
// +----------------------------------------------------------------------
// | Copyright (c) 2011 http://www.fanwe.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: 云淡风轻(88522820@qq.com)
// +----------------------------------------------------------------------

class sms_sender
{
	var $sms;
	
	public function __construct()
    { 	
		$sms_info = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."sms where is_effect = 1");
		if($sms_info)
		{
			$sms_info['config'] = unserialize($sms_info['config']);
             //	require_once APP_ROOT_PATH."system/utils/serverApi.php";
             //                $sms = new ServerAPI('fsockopen');     //fsockopen伪造请求

             //发送短信验证码
             //                $result = $sms->sendSmsCode($msg_item['templateid'],$msg_item['dest'],'',$msg_item['code']);
		}
        require_once APP_ROOT_PATH."system/sms/netease_sms.php";
        //$sms_class = $sms_info['class_name']."netease_sms";
        $this->sms = new netease_sms();
    }
    
	
	public function sendSms($netease_template_id ,$mobiles,$content)
	{
		if(!is_array($mobiles))
			//$mobiles = preg_split("/[ ,]/i",$mobiles);

		if($mobiles > 0 )
		{
			if(!$this->sms)
			{
				$result['status'] = 0;
			}
			else
			{
				$result = $this->sms->sendSmsCode($netease_template_id ,$mobiles,'',$content);

			}
		}
		else
		{
			$result['status'] = 0;
			$result['msg'] = "没有发送的手机号";
		}
		
		return $result;
	}
}
?>